package com.bw.z.mvp.view.people.adapter;

import android.widget.ImageView;

import com.blankj.utilcode.util.TimeUtils;
import com.bw.z.R;
import com.bw.z.mvp.model.entity.RecommendEntity;
import com.bw.z.network.Api;
import com.bw.z.utils.GlideUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import org.jetbrains.annotations.NotNull;

import java.util.Date;

public class RecommendAdapter extends BaseQuickAdapter<RecommendEntity.Values, BaseViewHolder> {
    public RecommendAdapter() {
        super(R.layout.item_video_recommend);
        addChildClickViewIds(R.id.video_recommend_play_img);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder baseViewHolder, RecommendEntity.Values values) {
        Date date = new Date(values.news_time * 1000);
        String timeStr = TimeUtils.getFriendlyTimeSpanByNow(date);
        baseViewHolder.setText(R.id.video_recommend_title_tv, values.news_title);
        baseViewHolder.setText(R.id.video_recommend_author_tv, values.news_author);

        baseViewHolder.setText(R.id.video_recommend_time_tv, "" + timeStr);
        ImageView imageView = baseViewHolder.getView(R.id.video_recommend_cover_img);
        GlideUtils.getInstance().GlideImage(Api.FileUrl + values.getMedias().get(0).media_url, imageView);
    }
}
